import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
import axios from 'axios'

export interface DO_NAME_TYPE {
  name: string
  age: number
}
export const useDemoStore = defineStore('DemoStore', () => {
  const name = ref('你好Pinia')
  const GETTER_NAME = computed(() => name.value + '--Comp')
  function SET_NAME(_name: string) {
    name.value = _name
  }
  async function doName(params: DO_NAME_TYPE) {
    SET_NAME('开始执行')
    console.log('doName开始')
    const resp = await axios.get('/api/long-time-get-req', {
      params: params,
    })
    console.log('resp', resp)
    SET_NAME('执行完毕')
  }
  return { name, SET_NAME, doName, GETTER_NAME }
})
